<template>
  <div class="mainBox">
     <div class="mainTitle">测验结果</div>
   <el-table :data="tableData" style="width: 100%" height=" calc(100vh - 310px)">
      <el-table-column type="index" width="60" label="序号" />
      <el-table-column prop="title" label="题目" width="" />
      <el-table-column prop="real_name" label="答题学生" width="" />
      <el-table-column prop="answer_time" label="答题时间" width="" />
      <el-table-column fixed="right" label="操作" width="120">
        <template #default="scope">
          <el-button class="secondBtnL" link @click="openDrawerComs(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
     <Pagination @tips="tips" ref="pagination" />
   <DrawerItem ref="drawerItem" />
  </div>
</template>
<script  setup>
import { resultList } from "../../api/index";
import { ref, onMounted } from "vue";
import Pagination from "../../components/Pagination/index.vue";

import DrawerItem from "./components/drawerItem.vue";

// 引用类型
const drawerItem = ref(null);
const tableData = ref([]);

const pagination = ref(null);

const getList = (val) => {
  // console.log(pagination.value.paginationData.currentPage);
  let parmas = {
    pageNo: val,
    pageSize: 10,
  };
  resultList(parmas).then((res) => {
    if (res.code == 200) {
      pagination.value.paginationData.currentPage = Number(val);
      pagination.value.paginationData.total = Number(res.data.total);
      tableData.value = res.data.records;
    }
  });
};
onMounted(() => {
  getList(1);
});

const tips = (data) => {
  console.log(data);
  getList(data);
};
const openDrawerComs = (item) => {
  drawerItem.value.drawerData.title = "查看结果";
  drawerItem.value.form.id = item.id;
  drawerItem.value.form.status = "";
  drawerItem.value.form.remarks = "";
  drawerItem.value.form.file = "";
  drawerItem.value.questionId = item.question_id;
  drawerItem.value.id = item.id;
  drawerItem.value.userId = item.user_id;

  drawerItem.value.getTopic(item.question_id)
  let data = {
    qid: item.question_id,
    userId: item.user_id,
    answerId: item.id
  }
  drawerItem.value.getInfo(data)
  drawerItem.value.drawerData.open = true;
};
</script>
<style lang="scss" scoped>
.mainBox {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  margin: 24px;
  min-height: calc(100vh - 56px - 48px - 40px);
  min-width: 1200px;
  overflow: auto;

  .mainTitle {
    font-size: 16px;
    font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
    font-weight: bold;
    color: #333333;
    margin-bottom: 16px;
    padding-top: 16px;
  }

  .btnBox {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
  }
}

:deep(.el-table) {
  --el-table-border-color: rgba(255, 255, 255, 0);

  .el-table__header .el-table__cell {
    background: #f7f8fa;
    font-size: 14px;
    font-family: MicrosoftYaHei;
    color: #333333;
    border-color: #ebebeb;
  }

  .el-table__header .is-group tr:first-child .el-table__cell {
    background: #f7f8fa;
  }

  .el-table__body .el-table__cell {
    padding: 0px;
    height: 32px;
    border-left: none;
    border-right: none;
    border-color: #ebebeb;
    font-size: 14px;
    font-family: MicrosoftYaHei;
    color: #666666;
  }

  .tableBtn {
    color: #155bd3;
    font-size: 14px;
    font-family: MicrosoftYaHei;
  }
}
</style>